<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入在线的leaflet依赖 -->
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.3/dist/leaflet.css"
        integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin="" />
    <script src="https://unpkg.com/leaflet@1.9.3/dist/leaflet.js"
        integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
    <!-- js依赖 -->
    <!-- <script src="https://lib.baomitu.com/leaflet/1.9.2/leaflet.js"></script> -->
    <!-- css依赖 -->
    <!-- <link rel="stylesheet" href="https://lib.baomitu.com/leaflet/1.9.2/leaflet.css"> -->
    <!-- 沿着坐标路径绘制图案 -->
    <script
        src="https://cdn.jsdelivr.net/npm/leaflet-polylinedecorator@1.6.0/dist/leaflet.polylineDecorator.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            height: 100vh;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <script>
        var url = 'https://api.mapbox.com/styles/v1/mapbox/streets-v11/tiles/{z}/{x}/{y}?access_token=pk.eyJ1IjoiY2hlbmdiZW5jaGFvIiwiYSI6ImNsODU3aGRiODA0Y2UzcHBzZmFlcmdqZ2sifQ.8k59W_pB_Riwe6o-MneRlA'
        var layer = L.tileLayer(url, {
            maxZoom: 19,
            attribution: '© OpenStreetMap'
        })
        const map = L.map("map", {
            center: [0, 0],
            zoom: 1,
            layers: [layer]
        })
        //绘制图层
        var drawnItems = new L.FeatureGroup();
        //添加绘制图层
        map.addLayer(drawnItems);
        /* 1.--------------------- */
        //绘制线
        var arrow = L.polyline([[15, -65], [20, -45]], {
            //颜色
            color: 'red'
        }).addTo(drawnItems);
        //添加箭头
        var arrowHead = L.polylineDecorator(arrow, {
            //添加模式
            patterns: [{
                //模式符号的偏移位置
                // offset: '0%',
                offset: '20px',
                //模式符号的重复间隔
                repeat: 30,
                //符号实例
                symbol: L.Symbol.arrowHead({
                    //符号大小
                    pixelSize: 10,
                    //符号样式
                    pathOptions: {
                        //是否显示边线
                        // stroke: false,
                        stroke: true
                    }
                })
            }]
        }).addTo(drawnItems);
    </script>
</body>

</html>